
	//填充视频内容
	function fillContent(contentArray,index,searchTxt){
		$(contentArray).each(function(i,item){
			var divHTML = "";
			var liveId = isValid(item.liveId,"");
			var title = item.liveTitle;
			var liveTitle = isValid(title,"");
			var liveImg = isValid(item.livePoster,"");
			var liveStatus = isValid(item.liveStatus,"");
			var livePrice = isValid(item.playPrice,0);
			var anchorName = isValid(item.anchorName,"");
			var showTime = isValid(item.showTime,"");
			var watchingNum = isValid(item.playCount,"0");   
			var video = $('#videoDiv').clone();
			if(liveStatus == "0" || liveStatus == "1"){ 
				video = $('#videoNoticeDiv').clone();
				showTime = getFormatTimeT(showTime);
				video.find("p:eq(0)").html(showTime+" 开播");    					
			}
			video.find(".ct_logo").find("img:eq(0)").attr("src",liveImg);
		    showTime = getFormatTimeT(showTime);
			video.find(".ct_info").find("h1:eq(0)").html(liveTitle);
			video.find(".ct_info").find("h2:eq(0)").html(anchorName);
			livePrice = parseFloat(livePrice);
			if(livePrice == 0){
				video.find(".ct_info").find("p:eq(0)").html("");
			}else{
				video.find(".ct_info").find("p:eq(0)").html("￥"+livePrice);
			}
			//video.find(".time").html(showTime);
			if(liveStatus == "2"){//直播中
				video.find(".ct_info").find("h3:eq(0)").find("span:eq(0)").html(watchingNum+"人看过");
				video.find(".ct_info").find("h3:eq(0)").show();
				video.find(".ct_info").find("h3:eq(1)").hide();
			}else{
				if(liveStatus == "0" || liveStatus == "1"){
					video.find(".ct_info").find("h3:eq(1)").html(watchingNum+"人报名");
				}else{
					video.find(".ct_info").find("h3:eq(1)").html(watchingNum+"人看过");
				}
				video.find(".ct_info").find("h3:eq(1)").show();
				video.find(".ct_info").find("h3:eq(0)").hide();
			}
		    video.find("li:eq(0)").attr("onclick","toLiveDetail('"+liveId+"')");
			
			var listId = "videoBackList";
			if(liveStatus == "0" || liveStatus == "1")listId="videoNoticeList";
			if(liveStatus == "2")listId="videoLiveList";
			video.show();
			divHTML += video.html();					
			if(index == 0){
				$("#"+listId).append(divHTML);
			}else{
				$("#"+listId).find("div:eq("+index+")").append(divHTML);	
			}
			$("#"+listId).show();
		});
		
	};
	
   //获取视频间隔时间
   function getFormatTimeT(date){
		if(date == null){
			return "";
		}
		var result = Math.abs(date-new Date().getTime())
		if(result < 60000){// 一分钟内
			var seconds = Math.floor(result / 1000);
			r = seconds + "秒前";
		}else if (result >= 60000 && result < 3600000){// 一小时内
			var seconds = Math.floor(result / 60000);
			r = seconds + "分钟前";
		}else if (result >= 3600000 && result < 86400000){// 一天内
			var seconds = Math.floor(result / 3600000);
			r = seconds + "小时前";
		}else if (result >= 86400000 && result < 259200000){// 三天内
			var seconds = Math.floor(result / 86400000);
			r = seconds + "天前";
		}else{
			r = new Date(date).Format("yyyy"+"年"+"MM"+"月"+"dd"+"日") ;
		}
		return r;
	}

    /**
	 * 填充首页视频
     * @param videoTemplate html 模板元素
     * @param videoContent html 要填充到的位置
     * @param data 数据
     */
	function fillIndexTopContent(topTemplate,topContent,data){
        $.each(data,function(i,d){
            var titleDiv = topTemplate.find(".title").clone();
            titleDiv.find("span").text(i);
            topContent.append(titleDiv);
            var videoTemplate = topTemplate.find("li:eq(0)");
			var videos = $("<div class='ido_live'></div>");
			fillVideos(videoTemplate,videos,d);
			topContent.append(videos);

        });
	}

    /**
	 * 多个视频填充
     * @param videoTemplate 模板
     * @param videoContent 填充位置
     * @param videos 数据
     */
	function fillVideos(videoTemplate,videosContent,videos){
        $(videos).each(function(i,item){
            var liveId = isValid(item.liveId,"");
            var title = item.liveTitle;
            var liveTitle = isValid(title,"");
            var liveImg = isValid(item.livePoster,"");
            var liveStatus = isValid(item.liveStatus,"");
            var livePrice = isValid(item.playPrice,0);
            var anchorName = isValid(item.anchorName,"");
            var showTime = isValid(item.showTime,"");
            var watchingNum = isValid(item.playCount,"0");
            var hasPassword = isValid(item.hasPassword,"");
            var orgId = isValid(item.cooperateOrgId,"");
            var video = videoTemplate.clone();
            video.find("h3").html("");
            
            //五四青年节活动
			if(liveId == "v2No4NriThaenckTMhq3dQ" || liveId == "8atQ0ZcTTGSGHi05BWN7JQ"){
				fakeNum = getFakeNum(showTime);
				watchingNum = parseInt(watchingNum) + fakeNum;
			}
			
            if(liveStatus === "0" || liveStatus === "1"){  //未开始
                var date = getDate(showTime);
                var time = getTime(showTime);
            	var showDiv = $("<div class='trailer_pop'>"+date+"<p>"+time+"</p></div>");
                video.find(".ct_logo").append(showDiv);
                video.find("h3").append(watchingNum+"人报名");
            }else if(liveStatus === "2"){ //直播中
                video.find("h3").html("<img src='images/live.gif'/><i class='tips'><img src='images/tips.png'></i><span>"+watchingNum+"人看过</span> ");
			}else {
                video.find("h3").html(watchingNum+"人看过");
			}
            video.find(".ct_logo").find("img:eq(0)").attr("src",liveImg);
            video.find(".ct_info").find("h1:eq(0)").html(liveTitle);
            //6.8个性添加
            if(orgId == 'tlNDpfjHSFqpNd7TuVfE_Q'){
            	video.find(".ct_info").find("h2:eq(0)").html("&nbsp;");	
            }else{
            	video.find(".ct_info").find("h2:eq(0)").html(anchorName);
            }
            var priceHtml = "";
            if(hasPassword){
        		//加锁
        		priceHtml += "<i><img src='images/encryption_blue.png'/></i>";
        	}
            livePrice = parseFloat(livePrice);
            if(livePrice > 0){
            	priceHtml += "￥"+livePrice;
            }
            video.find(".ct_info").find("p:eq(0)").html(priceHtml);
            //video.find(".time").html(showTime);
            video.attr("onclick","toLiveDetail('"+liveId+"')");
            videosContent.append(video);
        });
	}

    /**
	 * 获取日期 今天，明天，2017-10-10
     */
	function getDate(date){
        if(date == null){
            return "";
        }
        var nowyear = new Date().Format("yyyy");
        var nowday = new Date().Format("yyyyMMdd");
        var nowmonth =  new Date().Format("yyyyMM");

        var year = new Date(date).Format("yyyy");
        var day = new Date(date).Format("yyyyMMdd");
        var month =  new Date(date).Format("yyyyMM");

        if(nowday === day){
            r = "今天";
		}else if(month === nowmonth && nowday - day ==  -1){
            r = "明天";
		}else if(month === nowmonth && nowday - day == 1){
            r = "昨天";
		}else if(nowyear === year){
            r = new Date(date).Format("MM月dd日") ;
		}else {
            r = new Date(date).Format("yyyy年MM月dd日") ;
		}
        return r;
	}
    /**
     * 获取时间
     */
    function getTime(date){
        if(date == null){
            return "";
        }
        return new Date(date).Format("hh:mm") ;
    }